package dshop.model.procurement;

import java.util.Date;

import com.jfinal.plugin.activerecord.Db;

import appbase.jfinal.ext.BaseModel;
import dshop.AppConst;

public class Procurement extends BaseModel<Procurement> {

	private static final long serialVersionUID = -6967680902549117464L;

	public static final Procurement dao = new Procurement();

	public static final String STRUTS_NORMAL = "NORMAL";
	public static final String STRUTS_END = "END";

	public static void delete(int procurementId) {
		new Procurement().set("is_delete", AppConst.DELETE_STR_YES).set("delete_date_time", new Date())
				.set("id", procurementId).update();
	}

	public static void updateOperator(String operator,int procurementId) {
		Db.update("update bbs_procurement set operator = ? , operator_time = now() where id = ?",operator,procurementId);
	}

	public static void setCheckStatus(int procurementId, String checkStatus, String checkStatusExplain) {
		new Procurement().set("check_status", checkStatus).set("check_status_explain", checkStatusExplain)
				.set("check_date_time", new Date()).set("id", procurementId).update();
	}

	public static Procurement findPushCnt(String procurementId) {
		String sql = "select count(1) as 'count' from push_record where contentRefId = ?";
		return dao.findFirst(sql, procurementId);
	}

	public static void setEnd(int procurementId) {
		dao.updateColumnBy("end_date_time", "id", new Date(), procurementId);
	}

}
